package teleinfo

import "encoding/json"

type Status struct {
	Code        int
	Message     string
	OperationAt string `json:"operation_at"`
}

type Response struct {
	BussinessCode string `json:"bussiness_code"`
	Status        Status
}

type Result struct {
	Response `json:"ng_audit_epp_message_response"`
}

// ParseResponse parse json response
func ParseResposne(data []byte) Result {

	resp := Result{}

	err := json.Unmarshal(data, &resp)

	if err != nil {
		panic(err)
	}

	return resp
}

// 判断操作是否成功
func (r Result) IsSuccess() bool {
	return r.Status.Code == 0
}
